package cn.com.open.itembank.controller;

import cn.com.open.itembank.dto.ItemBankCount;
import cn.com.open.itembank.entity.CourseItemBank;
import cn.com.open.itembank.service.AppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by lucky on 2018/6/5.
 */
@RestController
@RequestMapping(value = "/app")
public class AppController {
    @Autowired
    AppService service;

    /**
     * 获取appKey列表
     *
     * @return appKey列表
     */
    @GetMapping
    public List<String> getAppList() {
        return service.getAppList();
    }

    /**
     * 根据appKey和orgid获取课程题库信息
     *
     * @param appKey 应用ID
     * @param orgId  机构ID
     * @return 可用题库列表
     */
    @GetMapping(value = "/{appKey}/org/{orgId}/itembanks")
    public List<CourseItemBank> getItembankListByAppKeyAndOrgId(@PathVariable("appKey") String appKey, @PathVariable(value = "orgId") String orgId) {
        return service.getItembankListByAppKeyAndOrgId(appKey, orgId);
    }

    /**
     * 根据appKey获取对应题库题量列表
     *
     * @param appKey 应用ID
     * @return 对应题库题量列表
     */
    @GetMapping(value = "/{appKey}/itembank/questioncount")
    public List<ItemBankCount> getItembankQuestionCountByAppKey(@PathVariable(value = "appKey") String appKey) {
        return service.getItembankQuestionCountByAppKey(appKey);
    }
}
